/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bm.main;

import com.bm.main.threading.TerminateApp;
import com.bm.main.threading.QueueFlagMessageOutbox;
import com.bm.config.server.IServerServices;
import com.bm.main.threading.QueueNewMember;
import com.bm.main.threading.QueueSyncLocalToWeb;
import com.bm.setting.ServerConfig;
import com.bm.util.MessagePrinter;
import com.bm.util.PropertiesHandler;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author ssm
 */
public class Main {

    private static Thread terminateApp = null;    
    private static Thread queueFlagMessageOutbox = null;
    private static Thread queueSyncLocalToWeb = null;
    private static Thread queueNewMember = null;
    private static int maksimumDataRequestOutbox = 0;
    public static String url_request = "";

    public static void main(String[] args) {
        MessagePrinter.printDebug("Beta Version - SMS Socket Server. Last update by Mirza");
        initConfig();
        
        PropertiesHandler properties = null;
        try {
            properties = new PropertiesHandler();
            maksimumDataRequestOutbox = properties.getMaksimumDataPerRequestOutbox();
            url_request = properties.urlRequest();
        } catch (IOException ex) {
            MessagePrinter.printDebug("Gagal load properties : "+ex.getMessage());
            System.exit(0);
        }
        
        terminateApp = new Thread(new TerminateApp());        
        queueFlagMessageOutbox = new Thread(new QueueFlagMessageOutbox(maksimumDataRequestOutbox, url_request));
        queueSyncLocalToWeb = new Thread(new QueueSyncLocalToWeb(maksimumDataRequestOutbox, url_request));
        queueNewMember = new Thread(new QueueNewMember(maksimumDataRequestOutbox, url_request));
                
        queueSyncLocalToWeb.start();
        terminateApp.start();
        queueFlagMessageOutbox.start();
        queueNewMember.start();
    }
    
    

    private static void initConfig() {
        try {
            ServerConfig sc = new ServerConfig(new IServerServices());
        } catch (IOException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
